<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./js/vue2.js"></script>
    <script src="./js/vue-router.js"></script>
</head>
<body>
    <div id="app">
        <router-link to="/index">首页</router-link>
        <router-link to="/login">登录页</router-link>
        <router-view></router-view>
    </div>
</body>
<script>
    // 创建组件
    var  index=Vue.component('index',{
        template:`<h1>首页</h1>`
    })
    var login = Vue.component('login',{
        template:`<h1>登录页</h1>`
    })
    // 创建路由对象
    var router = new VueRouter({
        routes:[
            {name:'index',path:'/index',component:index},
            {name:'login',path:'/login',component:login}
        ]
    })
    var  vm=new Vue({
        el:"#app",
        router:router,
        data:{

        }
    })
</script>
</html>